<template>
    <div class="domain-banner">
        <div class="container">
            <div class="index_banner">
                <el-carousel :interval="3000" type="card" :height="height">
                    <el-carousel-item v-for="(item,index) in bannerList" :key="index">
                        <router-link  :to="'/detail?contentId='+item.contentid"><img :src="item.bannerPic"></router-link>
                        <p class="banner-title">{{item.title}}</p>
                    </el-carousel-item>
                </el-carousel>
            </div>
        </div>
    </div>
</template>

<script>
import {fetch} from '../../utils/httpRequest'
export default {
    data:function(){
        return {
            height:'0px',
            bannerList:[]
        };
    },created:function(){
        this.beforeMount();
        this.getBanner();
    },methods:{
        beforeMount:function(){
            var screenWidth=document.body.clientWidth;
            if(screenWidth<500){
                this.height="150px"
            }else{
                this.height="280px"
            }
        },
        getBanner(){
           fetch(this.http.article_tourist.banner.getBanner,{}).then((response)=>{
               this.bannerList=response.data;
           })
        }
    }
}
</script>

<style scoped>
.banner-title{
    position: absolute;
    bottom: 20px;
    left: 0;
    z-index: 10;
    width: 100%;
    padding: 28px 16px 0;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.el-carousel__item h3 {
    color: #475669;
    font-size: 12px;
    opacity: 0.75;
}
.el-carousel__item img{
    width: 100%;
    height: 100%;
}
@media screen and (max-width: 500px) {
  .banner-title {
    bottom: 0px;
    padding: 28px 8px 0;
  }
}
</style>
